﻿using System;
using System.Drawing;

namespace Lant.Net.Controls
{
	public class PukeCard : System.Windows.Forms.PictureBox
	{
		private int _Index;
		private Puke puke;
		private bool _Selected = false;

		public bool Selected { get { return _Selected; } }
		public int Index { get { return _Index; } }
		public int NextValue { get { return 0; } }
		public string Display { get { return puke.GetCardDisplay(_Index); } }
		public string Sign { get { return puke.GetCardSign(_Index); } }

		public PukeCard(Puke thisCard, int thisValue)
		{
			this._Index = thisValue;
			this.puke = thisCard;
			this.Size = this.puke.CardSize;
			Point location = thisCard.GetCardLocation(thisValue);

			Image tempImg = new Bitmap(this.puke.CardSize.Width, this.puke.CardSize.Height);
			Graphics g = Graphics.FromImage(tempImg);
			g.DrawImage(this.puke.Card, new Rectangle(0, 0, this.puke.Card.Width, this.puke.Card.Height), new Rectangle(location.X, location.Y, this.puke.Card.Width, this.puke.Card.Height), GraphicsUnit.Pixel);
			this.Image = tempImg;
			this.Click += new EventHandler(PukeCard_Click);
		}

		void PukeCard_Click(object sender, EventArgs e)
		{
			if (_Selected)
				this.Top += 10;
			else
				this.Top -= 10;
			_Selected = !_Selected;
		}
	}
}
